﻿<UserControl
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:v="clr-namespace:SampleApplication.Views"
             xmlns:style="clr-namespace:Okazuki.MVVM.PrismSupport.Style;assembly=Okazuki.MVVM.PrismSupport"
             xmlns:SampleApplication_ViewModels="clr-namespace:SampleApplication.ViewModels" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:Custom="http://www.codeplex.com/prism" xmlns:Okazuki_MVVM_PrismSupport_Interactivity="clr-namespace:Okazuki.MVVM.PrismSupport.Interactivity;assembly=Okazuki.MVVM.PrismSupport" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" x:Class="SampleApplication.Views.MainView" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="553">
	<UserControl.Resources>
		<SampleApplication_ViewModels:MainViewModel x:Key="MainViewModelDataSource" d:IsDataSource="True"/>
		<SolidColorBrush x:Key="GridBorderBrush" Color="#FFADADAD"/>
    </UserControl.Resources>
    <Grid DataContext="{Binding Source={StaticResource MainViewModelDataSource}}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="265*" />
        </Grid.RowDefinitions>
        <i:Interaction.Triggers>
    		<Custom:InteractionRequestTrigger SourceObject="{Binding ShowPersonRequest, Mode=OneWay}">
    			<Okazuki_MVVM_PrismSupport_Interactivity:ShowWindowAction IsModalWindow="True" WindowType="{x:Type v:PersonWindow}"/>
    		</Custom:InteractionRequestTrigger>
    		<Custom:InteractionRequestTrigger SourceObject="{Binding ShowMessageRequest, Mode=OneWay}">
    			<Okazuki_MVVM_PrismSupport_Interactivity:NotificationContentHolderAction Value="{Binding Text, ElementName=textBlockMessage, Mode=TwoWay}"/>
    		</Custom:InteractionRequestTrigger>
    	</i:Interaction.Triggers>
        <GroupBox Grid.Row="1" Header="メッセージ" Margin="2">
            <TextBlock x:Name="textBlockMessage" />
        </GroupBox>
        <DataGrid AutoGenerateColumns="False" x:Name="dataGrid1" ItemsSource="{Binding People}" EnableColumnVirtualization="True" IsReadOnly="True" Grid.Row="2" Margin="5" HorizontalGridLinesBrush="{DynamicResource GridBorderBrush}" VerticalGridLinesBrush="{DynamicResource GridBorderBrush}">
        	<DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Name}" Header="名前" MinWidth="50" />
                <DataGridTextColumn Binding="{Binding Birthday, StringFormat=yyyy年MM月dd日}" Header="生年月日" MinWidth="50" />
                <DataGridTemplateColumn Header="操作">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Button Content="編集" Command="{Binding Path=EditCommand}" />
                                <Button Content="削除">
                                    <i:Interaction.Triggers>
                                        <i:EventTrigger EventName="Click">
                                            <i:Interaction.Behaviors>
                                                <Okazuki_MVVM_PrismSupport_Interactivity:ConfirmPreviewActionBehavior
                                                    Message="選択項目を削除してもよろしいですか" />
                                            </i:Interaction.Behaviors>
                                            <Okazuki_MVVM_PrismSupport_Interactivity:ExtendedInvokeCommandAction Command="{Binding Path=DeleteCommand}" />
                                        </i:EventTrigger>
                                    </i:Interaction.Triggers>
                                </Button>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
        <StackPanel Orientation="Horizontal" Margin="5">
            <TextBox x:Name="textBoxSearch" Width="100" Margin="2"/>
            <Button Content="検索" Command="{Binding LoadCommand, Mode=OneWay}" MinWidth="75" Margin="2" CommandParameter="{Binding Text, ElementName=textBoxSearch}" />
            <Button Content="編集..." Command="{Binding EditCommand, Mode=OneWay}" CommandParameter="{Binding SelectedItem, ElementName=dataGrid1}" MinWidth="75" Margin="2" />
            <Button Command="{Binding InsertCommand, Mode=OneWay}" Content="追加..." MinWidth="75" Margin="2" />
            <Button Content="削除" Height="23" x:Name="button1" MinWidth="75" Margin="2">
            	<i:Interaction.Triggers>
            		<i:EventTrigger EventName="Click">
            			<i:Interaction.Behaviors>
                            <Okazuki_MVVM_PrismSupport_Interactivity:ConfirmPreviewActionBehavior
                                Message="選択項目を削除してもよろしいですか" />
                        </i:Interaction.Behaviors>
                        <Okazuki_MVVM_PrismSupport_Interactivity:ExtendedInvokeCommandAction Command="{Binding Path=DeleteCommand}" CommandParameter="{Binding ElementName=dataGrid1, Path=SelectedItem}" />
            		</i:EventTrigger>
            	</i:Interaction.Triggers>
            </Button>
            <TextBlock Name="textBlock1" Text="About" Margin="2"  VerticalAlignment="Center" Foreground="Blue" TextTrimming="None">
                <TextBlock.Style>
                    <!-- StyleでTriggerを設定する例 -->
                    <Style TargetType="{x:Type TextBlock}">
                        <Setter Property="style:StyleInteraction.Triggers">
                            <Setter.Value>
                                <style:StyleTriggerCollection>
                                    <i:EventTrigger EventName="MouseLeftButtonDown">
                                        <Okazuki_MVVM_PrismSupport_Interactivity:ShowMessageBoxAction
                                            Title="バージョン情報"
                                            Content="SampleApplicationバージョン1.1" />
                                    </i:EventTrigger>
                                </style:StyleTriggerCollection>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </TextBlock.Style>
            </TextBlock>
        </StackPanel>
    </Grid>
</UserControl>
